package nl.vu.few.ibivu.biomodels.client.event;

import nl.vu.few.ibivu.biomodels.client.activity.ModelActivityState;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;

public class ModelChangedEvent extends GwtEvent<ModelChangedEventHandler> {

	private final ModelActivityState state;
	public static Type<ModelChangedEventHandler> TYPE = new Type<ModelChangedEventHandler>();

	public ModelChangedEvent(ModelActivityState state) {
		this.state = state;
	}
	
	public ModelActivityState getState() {
		return state;
	}

	@Override
	public com.google.gwt.event.shared.GwtEvent.Type<ModelChangedEventHandler> getAssociatedType() {
		return TYPE;
	}

	@Override
	protected void dispatch(ModelChangedEventHandler handler) {
		handler.onChange(this);
	}

	public static HandlerRegistration register(EventBus eventBus, ModelChangedEventHandler handler) {
		return eventBus.addHandler(TYPE, handler);
	}

}
